/**
 * 
 */
package com.surelution.lansao.wxmp

/**
 * @author <a href="mailto:guangzong.syu@gmail.com">Guangzong</a>
 *
 */
class IdRefuser {
	
	private static char[] cs = ['Z','a','m','c','o','p','Q','3','R','k','9','I','d','z','J','5','F','6','v','q','l','j','B','b','r','A','x','h','u','n','s','1','e','f','7','8','t','g','i','w','y','C','2','D','E','G','H','K','0','L','M','N','O','P','S','T','U','V','W','X','Y','0'];

	public static String getRefusedId(long orig) {
		int i = orig
		StringBuilder sb = new StringBuilder()
		while(true) {
			if(i >= 62) {
				sb.insert(0, cs[i % 62]);
				i = i / 62;
			} else {
				sb.insert(0, cs[i]);
				break;
			}
		}
		return sb.toString()
	}
	
	private static int getIndex(String s) {
		char c = s.charAt(0)
		cs.findIndexOf {
			it == c
		}
	}
	
	public static long reverseId(String refusedId) {
		long ret = 0
		refusedId.each {
			ret = ret * 62 + getIndex(it)
		}
		ret
	}
	
	public static void main(String[] args) {
		System.out.println(getRefusedId(1111111111));
		
		System.out.println(reverseId("azdQHX"));
	}
}
